#include <stdio.h>

int Square(int x,int y)
{
    int sum = 0;

    for(int i = 0;i < x;++i)
    {
        for(int j = 0;j < y;++j)
        {
            if(i == 0 || i == (x - 1) || i == 1 || i == (x - 2))
            {
                printf("*");
                ++sum;
            }
            else if(j == 0 || j == y - 1 || j == 1 || j == (y - 2))
            {
                printf("*");
                ++sum;
            }
            else
            {
                printf(" ");
            }
        }
        printf("\n");
    }

    return sum;
}

int main()
{
    int x , y ;
    
    printf("Row:");
    scanf("%d",&x);
    printf("Line:");
    scanf("%d",&y);

    int ret = Square(x,y);

    printf("人数:%d\n",ret);

    return 0;
}